﻿<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: head('登录')"></head>
<link rel="stylesheet" type="text/css" th:href="@{/css/login.css}" />
<body>
<div class="lay-user-login-top lay-user-display-show" id="lay-user-login" style="display: none;">
    <div class="lay-user-login-main">
        <div class="lay-user-login-box lay-user-login-header">
            <h2>管理系统</h2>
            <p>登录</p>
        </div>
        <form class="lay-user-login-box lay-user-login-body layui-form" th:action="@{/login}" method="post">
            <div class="layui-form-item">
                <label class="lay-user-login-icon layui-icon layui-icon-username" for="lay-login-username"></label>
                <input type="text" name="username" id="lay-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="lay-user-login-icon layui-icon layui-icon-password" for="lay-login-password"></label>
                <input type="password" name="password" id="lay-login-password" lay-verify="pass" placeholder="密码" class="layui-input">
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="lay-user-login-icon layui-icon layui-icon-vercode" for="lay-login-captcha"></label>
                        <input type="text" name="captcha" id="lay-login-captcha" lay-verify="required" placeholder="验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img th:src="@{/kaptcha}" class="lay-user-login-codeimg" id="lay-get-captcha" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;">
                <input type="checkbox" name="remember" value="on" lay-skin="primary" class="lay-fff" title="记住密码" />
            </div>
            <div class="layui-form-item">
                <button id="LAY-submit" class="layui-btn layui-btn-fluid" lay-submit lay-filter="lay-login-submit">登 入</button>
                <input type="hidden" id="tips" th:value="${tips}" />
            </div>
        </form>
    </div>
    <div th:include="include :: footer"></div>
</div>
<script>
layui.use(['form', 'jquery', 'layer'], function () {
    var form = layui.form, layer = layui.layer, $ = layui.jquery;
    if (top.location != self.location) top.location = self.location;
    document.onkeydown = function (e) { // 回车提交表单
        var theEvent = window.event || e;
        var code = theEvent.keyCode || theEvent.which;
        if (code == 13) {
            $("#LAY-submit").trigger("click");
        }
    }
    //提交
    form.on('submit(lay-login-submit)', function (data) {
        form.verify({
            pass: [
                /^[\S]{5,12}$/
                , '密码必须5到12位，且不能出现空格'
            ]
        });
    });
    var errorMsg = $("#tips").val();
    if (errorMsg) {
        layer.msg(errorMsg, {icon: 5});
    }
});
</script>
</body>
</html>